package test.ioc.service;


import com.why.simpleboot.core.annotation.ioc.Component;
import test.ioc.bean.User;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 *
 * 测试能够注入一个类
 * @author yasuo
 */
@Component
public class UserService {
    List<User> list = new ArrayList<>();

    public UserService(){

    }
    public UserService(List<User> list) {
        this.list = list;
    }

    public User getUserById(Integer id) {
        if (list.size() == 0 || id > list.size()) {
            return new User(404, UUID.randomUUID().toString() + "数组里面没有这个人！");
        }else {
            return list.get(id);
        }
    }
    public List<User> addUser(User user) {
        for (int i = 0; i < user.getId(); i++) {
            list.add(new User(user.getId(), user.getName() + "--->" + UUID.randomUUID().toString()));
        }
        return list;
    }
    public void say() {
        System.out.println("歪比歪比？");
    }
}
